
//############底部帮助中心
// 组件入口
Comps.BottomHelpCenterComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.contentUrl = option.contentUrl;
}

Comps.BottomHelpCenterComp.prototype.init = function(){
	var that = this;
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		var compId = this.compId;
		$.ajax({
			  type: "GET",
		      url: ContextPath+"/bottomHelpCenterComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	  that.genCompHtml(data);
		    	  Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		Utils.ajaxLoadComplate(that);
	}
}

Comps.BottomHelpCenterComp.prototype.genCompHtml = function (data){
	var compId = this.compId; 
	var contentUrl = this.contentUrl;
	 var htmlStr = "";
	 for(var i = 0;i<data.length;i++){
		 var cat = data[i].key;
		 
		 htmlStr += "<dl>";
		 htmlStr += "<dt><img src="+cat.iconPath+" /></dt>";
		 htmlStr += "<dd class='w_footerh'>"+cat.categoryName+"</dd>";
		 var conList = data[i].value;
		 for(var j=0;j<conList.length;j++){
			 var con = conList[j];
	    	 if(con.contentType == 1){
	    		 htmlStr +="<dd><a target='_blank' href='"+ContextPath+contentUrl+"&contentUuid="+con.contentUuid+"'>"+con.contentTitle+"</a></dd>";
	    	 }
	    	 if(con.contentType == 2){
	    		 htmlStr += "<dd><a target='_blank' href='"+con.contentValue+"' >"+con.contentTitle+"</a></dd>";
	    	 }
		 }
		 htmlStr += "</dl>";
	 }
	 $("#"+compId+"_cotcont").html(htmlStr);
}




//************************底部组件****************
Comps.BottomComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
}

Comps.BottomComp.prototype.init = function(){
	var that = this;
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		var compId = this.compId;
		 //异步获取数据
        $.ajax({
            type: "GET",
            url: ContextPath+"/bottomComp/ajaxLoadData",
            data: {},
            success: function(data) {
                $("#"+compId+"_content").html(data);
                Utils.ajaxLoadComplate(that);
            }
        });
	}else{
		Utils.ajaxLoadComplate(that);
	}
}




///////************************浏览足迹
Comps.ViewRecordsComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.productDetailUrl = option.productDetailUrl;
}

//加载浏览记录数据
Comps.ViewRecordsComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	Utils.ajaxLoadComplate(that);
	
	$("#"+compId+"_product_list").empty();
	//展示浏览足迹
	that.showViewRecords();
	
}

//显示浏览记录
Comps.ViewRecordsComp.prototype.showViewRecords = function(){
	var compId = this.compId
	var productDetailUrl = this.productDetailUrl;
	//var customerId = userId || localStorage.getItem('userId');
	var viewRecords = localStorage.getItem('_viewRecords2');
    
	if(viewRecords != null && viewRecords != ""){
		 var viewRecordsArray = JSON.parse(viewRecords);
		 var recordsHTML = "";
		 for (var k in viewRecordsArray){

			 var product = viewRecordsArray[k];
			 var imgurl3 = product.bigImageUrl;

			 var pId = product.productUuid;
			 var name = product.productName;
			 var price = product.shopPrice;
			 var saleCount = product.saleCount;
			 var privilegeTypes = product.privilegeTypes || [];

			 recordsHTML += '<li class="item"><a href="'+ContextPath+productDetailUrl+'&productUuid='+ pId + '">';
			 recordsHTML += '<b><img src="' + imgurl3 + '" id="imgPath3"></b></a>';
			 recordsHTML += '<div><p class="tit"><font>' + name + '</font></p>';
			 recordsHTML += '<strong class="price">￥' + price + '</strong><span class="haspay">' + saleCount + '人付款</span>';
			 recordsHTML += '</div></li>';
		 }
		 $("#"+compId+"_product_list").html("<ul>" + recordsHTML + "</ul></div>");
	 }
}



/////***************************友情链接******************888888888888888
Comps.UsefulLinksComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
}

//加载友情链接数据
Comps.UsefulLinksComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$.ajax({
			  type: "GET",
		      url: ContextPath+"/usefulLinksComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	 $("#"+compId+"_usefulLinks").empty();
		    	 for(var i=0;i<data.length;i++){
		    		 $("#"+compId+"_usefulLinks").append("<a href='"+data[i].siteLinks+"'>"+data[i].siteName+"</a>&nbsp;&nbsp;");
		    	 }
		    	 
		    	 Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		Utils.ajaxLoadComplate(that);
	}
}



////***********************顶部组件*****************
Comps.TopComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
}

Comps.TopComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$.ajax({
			  type: "GET",
		      url: ContextPath+"/topComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	  that.genViewHtml(data);
		    	  that.bindSomeEvent();
		    	  Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		that.bindSomeEvent();
		Utils.ajaxLoadComplate(that);
	}
	
	var subTopic = this.option.subTopic;
	if(subTopic != null && subTopic != ""){
		var topicList = subTopic.split(",");
	    $.each(topicList,function(){
	         CompMessage.subscribe(this,function(option,callback){
		         //订阅到登录成功刷新顶部
	        	 $.ajax({
		   			  type: "GET",
		   		      url: ContextPath+"/topComp/ajaxLoadData",
		   		      data: {},
		   		      dataType: "json",
		   		      success: function(data){
		   		    	  that.genViewHtml(data);
		   		      }
	        	 });
	         });
	    });
	}
}

Comps.TopComp.prototype.genViewHtml = function(data){
      var compId = this.compId;
	  var platName = data.platName;
	  $("#"+compId+"_em_platName").html(platName);
	  var nickName = data.nickName;
	  if(nickName != null && nickName != ""){
		  $("#"+compId+"_a_nickname").show();
		  $("#"+compId+"_a_nickname").attr("href",ContextPath+this.option.txt_customerIndexUrl).html(nickName);
	      $("#"+compId+"_a_login").hide();
	      $("#"+compId+"_a_register").hide();
	      $("#"+compId+"_a_myorder").show();
		  $("#"+compId+"_a_myorder").attr("href", ContextPath+this.option.txt_myorderUrl).html(this.option.lbl_myorderName);
		  $("#"+compId+"_a_logout").show();
		  $("#"+compId+"_a_logout").html(this.option.lbl_logoutName);
	  }else{
		  $("#"+compId+"_a_nickname").hide();
	  	  $("#"+compId+"_a_logout").hide();
	  	  $("#"+compId+"_a_myorder").hide();
	      $("#"+compId+"_a_login").show();
		  $("#"+compId+"_a_login").attr("href", ContextPath+this.option.txt_loginUrl).html(this.option.lbl_loginName);
		  $("#"+compId+"_a_register").show();
		  $("#"+compId+"_a_register").attr("href", ContextPath+this.option.txt_regUrl).html(this.option.lbl_regName);
	  }	
	$("#"+compId+"_a_index").attr("href", ContextPath+this.option.txt_indexUrl).html(this.option.lbl_indexName);
	$("#"+compId+"_a_favproduct").attr("href", ContextPath+this.option.txt_favProductUrl).html(this.option.lbl_favProductName);
	$("#"+compId+"_a_favstore").attr("href", ContextPath+this.option.txt_favStoreUrl).html(this.option.lbl_favStoreName);
	$("#"+compId+"_a_store").attr("href", ContextPath+this.option.txt_storeUrl).html(this.option.lbl_storeName);
	$("#"+compId+"_a_toapply").attr("href", ContextPath+this.option.txt_toApplyUrl).html(this.option.lbl_toApplyName);
	$("#"+compId+"_a_helpcenter").attr("href", ContextPath+this.option.txt_helpCenterUrl).html(this.option.lbl_helpCenterName);
}



//绑定事件
Comps.TopComp.prototype.bindSomeEvent=function(){
	var compId = this.compId;
	var that = this;
	
	$("#"+compId+"_a_logout").click(function(){
		$.getJSON(ContextPath+"/topComp/logout",{},function(data){
			if(data == "true"){
				window.location.href = ContextPath + "/" +that.option.txt_logoutUrl;
			}
		});
	});
}

//******************************登录组件******************************
Comps.LoginComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
}

//异步加载数据
Comps.LoginComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	 var hasVilidateCode = $("#"+compId+"_hasVilidateCode").val();
	 if(hasVilidateCode == "true"){
		 $("#"+compId+"_validateCodeDiv").show();
		 that.flushValidateCode();
	 }else{
		 $("#"+compId+"_validateCodeDiv").hide();
	 }
	var ref ='';  
	if (document.referrer.length > 0) {  
		ref = document.referrer;  
	}  
	try {  
		if (ref.length == 0 && opener.location.href.length > 0) {  
			ref = opener.location.href;  
		}  
	} catch (e) {
			 
	} 
	if(ref !=''){
		$("#referrer").val(ref);
	}
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$.ajax({
			 type: "GET",
		      url: ContextPath+"/loginComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	  that.genViewHtml(data);
		    	  that.bindSomeEvent();
		    	  Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		that.bindSomeEvent();
		Utils.ajaxLoadComplate(that);
	}
}

//初始化页面数据
Comps.LoginComp.prototype.genViewHtml = function(data){
	  var compId = this.compId;
	  $("#"+compId+"_loginName").val(data.loginName);
	  $("#"+compId+"_pwd").val(data.pwd);
	  var hasVilidateCode = data.hasVilidateCode;
	  $("#"+compId+"_hasVilidateCode").val(hasVilidateCode);
	  if(hasVilidateCode == "true"){
		  $("#"+compId+"_validateCodeDiv").show();
	  }else{
		  $("#"+compId+"_validateCodeDiv").hide();
	  }
	  var remember = data.remember;
	  if(remember == "on"){
		  $("#"+compId+"_remember").attr("checked","checked");
	  }else{
		  $("#"+compId+"_remember").removeAttr("checked");
	  }
	  $("#"+compId+"_a_reg").attr("href",ContextPath+"/"+this.option.a_forgetPwdUrl).html(this.option.a_forgetPwdName);
	  $("#"+compId+"_a_forgetpwd").attr("href",ContextPath + "/"+this.option.a_regUrl).html(this.option.a_regName);
}

//绑定事件
Comps.LoginComp.prototype.bindSomeEvent=function(){
	var compId = this.compId;
	var that = this;
	
	$("#"+compId+"_loginName").blur(function(){
		var loginName = $("#"+compId+"_loginName").val();
		if(loginName == null || loginName == ""){
			$("#errorMsg").html("请输入用户名/手机");
			$("#errordiv").show();
			return false;
		}else{
			$("#errorMsg").html("");
			$("#errordiv").hide();
		}
	});

	$("#"+compId+"_pwd").blur(function(){
		var password = $("#"+compId+"_pwd").val();
		if(password == null || password == ""){
			 $("#errorMsg").html("请输入密码");
			 $("#errordiv").show();
			 return false;
		}else{
			 $("#errorMsg").html("");
			 $("#errordiv").hide();
			 $("#"+compId+"_pwd").val(hex_md5($("#"+compId+"_pwd").val()));
		}
	});
	
	//点击验证码刷新验证码
	$("#"+compId+"_validateImg").click(function(){
		that.flushValidateCode();
	});
	
	//点击换一张，刷新验证码
	$("#"+compId+"_a_changecode").click(function(){
		that.flushValidateCode();
	});
	
	$("#y_loadlogin").click(function(){
		that.doCheckAndSubmit();
	});
}


/* 刷新验证码 */
Comps.LoginComp.prototype.flushValidateCode = function(){
	 var compId = this.compId;
	 var validateImgObject = document.getElementById(""+compId+"_validateImg");
	 validateImgObject.src = ContextPath+"/getCustomerLoginCode?time=" + new Date();
}

//验证用户名、密码，提交
Comps.LoginComp.prototype.doCheckAndSubmit = function(){
	 var compId = this.compId;
	 var that = this;
	 var redirectUrl = ContextPath+this.option.redirectUrl
	 var loginName = $("#"+compId+"_loginName").val();
	 if(loginName == null || loginName == ""){
		  $("#errorMsg").html("请输入用户名/手机");
		  $("#errordiv").show();
		  return false;
	  }
	 var pwd = $("#"+compId+"_pwd").val();
	 if(pwd == null || pwd == ""){
		 $("#errorMsg").html("请输入密码");
		 $("#errordiv").show();
		 return false;
	 }
	 
	 var hasVilidateCode = $("#"+compId+"_hasVilidateCode").val();
	 if(hasVilidateCode == "true"){
		 var validateCode = $("#validateCode").val();
		 if(validateCode == null || validateCode == ""){
			 $("#errorMsg").html("请输入验证码");
			 $("#errordiv").show();
			 return false;
		 }
	 }
	 var validateCode = $("#validateCode").val();
	 var remember = "";
	 $("input[name='remember']:checked").each(function(){
		 remember = $(this).val();
	 });
	 $.ajax({
		 type: "POST",
	      url: ContextPath+"/loginComp/login",
	      data: {
	    	  loginName : loginName,
	    	  pwd : pwd,
	    	  hasVilidateCode : hasVilidateCode,
	    	  validateCode:validateCode,
	    	  remember:remember
	      },
	      dataType: "json",
	      success: function(data){
	    	  if(data.flag == true){
	    		  window.location.href = redirectUrl;
	    	  }else{
	    		  $("#errorMsg").html(data.error_Msg);
	 			  $("#errordiv").show();
	 			  if(data.hasValidateCode == true){
	 				 $("#"+compId+"_hasVilidateCode").val("true");
	 				 $("#"+compId+"_validateCodeDiv").show();
	 				 that.flushValidateCode();
	 			  }
	 			  return false;
	    	  }
	      }
	});
}



///************************弹出登录框组件*******************
Comps.PopLoginComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
}

//异步加载数据
Comps.PopLoginComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	var subTopic = this.option.subTopic;
	if(subTopic != null && subTopic != ""){
		var topicList = subTopic.split(",");
	    $.each(topicList,function(){
	         CompMessage.subscribe(this,function(option,callback){
		            //弹出登录框
					$.getJSON(ContextPath+"/popLoginComp/isLogin",{},function(data){
						if(data.flag == false){
							$("#modal-login-form").modal();
							$('#y_loadlogin_id').unbind("click");
							$("#y_loadlogin_id").click(function(){
								that.customerlogin(callback);
							});
						}else{
							if(callback){
				        		 callback();
				        	}
						}
					});
	         });
	    });
	}
	
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$.ajax({
			 type: "GET",
		      url: ContextPath+"/popLoginComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	  that.genViewHtml(data);
		    	  that.bindSomeEvent();
		    	  Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		that.bindSomeEvent();
		Utils.ajaxLoadComplate(that);
	}
}


Comps.PopLoginComp.prototype.genViewHtml = function(data){
	 var compId = this.compId;
	 
	 $("#"+compId+"_loginName").val(data.loginName);
	 $("#"+compId+"_pwd").val(data.pwd);
	
	 var remember = data.remember;
	 if(remember == "on"){
		  $("#"+compId+"_remember").attr("checked","checked");
	 }else{
		  $("#"+compId+"_remember").removeAttr("checked");
	 }
	  
	 $("#"+compId+"_a_reg").attr("href",ContextPath+this.option.a_forgetPwdUrl).html(this.option.a_forgetPwdName);
	 $("#"+compId+"_a_forgetpwd").attr("href",ContextPath+this.option.a_regUrl).html(this.option.a_regName);
}


Comps.PopLoginComp.prototype.bindSomeEvent = function(){
	var compId = this.compId;
	var that = this;
	$("#y_loadlogin_id").click(function(){
		that.customerlogin();
	});
	
	$("#"+compId+"_loginName").blur(function(){
		var loginName = $("#"+compId+"_loginName").val();
		if(loginName == null || loginName == ""){
			$("#error_msg").html("请输入用户名/手机");
			$("#errordiv").show();
			return false;
		}else{
			$("#error_msg").html("");
			$("#errordiv").hide();
		}
	});
	
	$("#"+compId+"_pwd").blur(function(){
		var password = $("#"+compId+"_pwd").val();
		if(password == null || password == ""){
			 $("#error_msg").html("请输入密码");
			 $("#errordiv").show();
			 return false;
		}else{
			 $("#error_msg").html("");
			 $("#errordiv").hide();
			 $("#"+compId+"_pwd").val(hex_md5($("#"+compId+"_pwd").val()));
		}
	});
	
}


//验证用户名、密码，提交
Comps.PopLoginComp.prototype.customerlogin = function(cal){
	var that = this;
	var compId = this.compId;
	var loginName = $("#"+compId+"_loginName").val();
	if(loginName == null || loginName == ""){
		$("#error_msg").html("请输入用户名/手机");
		$("#errordiv").show();
		return false;
	}else{
		$("#error_msg").html("");
		$("#errordiv").hide();
	}

	var pwd = $("#"+compId+"_pwd").val();
	if(pwd == null || pwd == ""){
		 $("#error_msg").html("请输入密码");
		 $("#errordiv").show();
		 return false;
	}else{
		 $("#error_msg").html("");
		 $("#errordiv").hide();
	}
	var hasVilidateCode =  $("#"+compId+"_hasVilidateCode").val();
	if(hasVilidateCode == "true"){
		 var validateCode = $("#"+compId+"_validateCode").val();
		 if(validateCode == null || validateCode == ""){
			 $("#error_msg").html("请输入验证码");
			 $("#errordiv").show();
			 return false;
		 }else{
			 $("#error_msg").html("");
			 $("#errordiv").hide();
		 }
	 }
	var validateCode =  $("#validateCode").val();
	var remember = "";
	$("input[name='remember']:checked").each(function(){
		 remember = $(this).val();
	});
	
	 $.ajax({
		 type: "POST",
	      url: ContextPath+"/popLoginComp/quickLogin",
	      data: {
	    	  "loginName":loginName,
				"pwd":pwd,
				"hasVilidateCode":hasVilidateCode,
				"validateCode":validateCode,
				"remember":remember,
				"type":"customer",
				ranNum : Math.random()
	      },
	      dataType: "json",
	      success: function(data){
	    	  if(data.flag == true){
					$("#modal-login-form").modal('hide');//关闭模态框
					alert("登录成功！");
					//window.location.reload(); //登录成功后，刷新当前页面
					if(cal){
						cal();
					}
					var pubTopic = that.option.pubTopic;
					if(pubTopic != null && pubTopic != ""){
						//发布登录成功主题
						CompMessage.publish(pubTopic,{},function(){
							
						});
					}
					
			  }else{
					$("#error_msg").html(data.error_Msg);
		 			$("#errordiv").show();
		 			return false;
			  }
	      }
	});
}




////****************注册组件**************************
Comps.RegisterComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
	this.wait = 60;
}

//异步加载数据
Comps.RegisterComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	that.flushValidateCode();//刷新验证码
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$("#"+compId+"_a_login").attr("href",ContextPath+this.option.a_loginUrl).html(this.option.a_loginName);;
		$.ajax({
			  type: "GET",
		      url: ContextPath+"/registerComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	  var token = data.token;
		    	  $("#"+compId+"_token").val(token);
		    	  $("#"+compId+"_agreediv").html(data.regAgreement);
		    	  that.bindSomeEvent();
		    	  Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		  that.bindSomeEvent();
		  Utils.ajaxLoadComplate(that);
	}
}

Comps.RegisterComp.prototype.bindSomeEvent = function(){
	var that = this;
	$("#resigetName").blur(function(){
		that.checkResigetName();
	});
	
	$("#sendMobileCode").click(function(){
		that.time($(this));
		that.sendMobileCode();
	});
	
	$("#mobileCode").blur(function(){
		that.checkMobileCode();
	});
	
	$("#customerName").blur(function(){
		that.checkCustomerName();
	});
	$("#invitationCode").blur(function(){
		that.checkInvitationCode();
	});
	
	$("#passWord").blur(function(){
		that.checkPassWord();
	});
	
	$("#repeatPassWord").blur(function(){
		that.checkRepeatPassWord();
	});
	
	$("#verificationCode").blur(function(){
		that.checkVerificationCode();
	});
	
	$("#agreeProtocol").click(function(){
		$("#agreement").attr("checked","checked");
	});
	
	//修改密码强弱校验  
	 $("#passWord").change(function(e) {
		 var newpwd = $(this).val();
	 	 EvalPwd(newpwd) ;
	 	if(ClientSideStrongPassword(newpwd,gSimilarityMap,gDictionary)){	
	 		$("#pwdStrength").val("3");
	    }else if(ClientSideMediumPassword(newpwd,gSimilarityMap,gDictionary)){
	    	$("#pwdStrength").val("2");
	    }else if(ClientSideWeakPassword(newpwd,gSimilarityMap,gDictionary)){
	    	$("#pwdStrength").val("1");
	    }else{
		    $("#pwdStrength").val("0");
	    }
	 });  
	 
	 //修改密码强弱校验  
	 $("#passWord").keyup(function(e) {
		 var newpwd = $(this).val();
	 	 EvalPwd(newpwd) ;
	 	if(ClientSideStrongPassword(newpwd,gSimilarityMap,gDictionary)){	
	 		$("#pwdStrength").val("3");
	    }else if(ClientSideMediumPassword(newpwd,gSimilarityMap,gDictionary)){
	    	$("#pwdStrength").val("2");
	    }else if(ClientSideWeakPassword(newpwd,gSimilarityMap,gDictionary)){
	    	$("#pwdStrength").val("1");
	    }else{
	    	$("#pwdStrength").val("0");
	    }
	 });
	 
	 $("#img_changecode").click(function () {
		 that.flushValidateCode();
    });
	 
	 $("#a_changecode").click(function () {
		 that.flushValidateCode();
    });
	 $("#saveCustomerRegister").click(function () {
		 that.saveCustomerRegister();
    });
}


Comps.RegisterComp.prototype.time = function(o) {
    var that = this;
	if (this.wait == 0) {
        o.removeClass("disabled");
        o.text("重新获取验证码");
        this.wait = 60;
        $("#success").hide();
    } else {
        o.addClass("disabled");
        o.text(this.wait+"秒后重发");
        this.wait--;
        setTimeout(function() {
            that.time(o)
        },
        1000);
    }
}


//验证手机号/邮箱
Comps.RegisterComp.prototype.checkResigetName = function(){
	var that = this;
	var resigetName=$("#resigetName").val();	
	var mobile = /^1\d{10}$/;
	/* var email = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/; */
	if(mobile.test(resigetName)){
		$("#checkMobileCode").val("false");
		//$(".y_mobelyz").hide();
		$("#resigetNameError").text("");
		$("#resigetNameType").val("mobile");
		that.existMobile(resigetName);
	}else{
		$(".y_mobelyz").hide();
		$("#resigetNameType").val("");
		$("#resigetNameError").text("请填写正确的手机号!");
		$("#checkResigetName").val("false");	
	}
	
}

Comps.RegisterComp.prototype.existMobile = function(mobile){
	    var compId = this.compId;
		var url = ContextPath+"/registerComp/checkMobile";
		var token=$("#"+compId+"_token").val();
		$.ajaxSettings.async = false;
		$.getJSON(url,{mobile:mobile,ranNum:Math.random(),token:token},function(data){
				if(data=="false"){
					$("#resigetNameError").text("");
					$("#checkResigetName").val("true");
					$(".y_mobelyz").show();
					$(".w_1280").css("padding-bottom","20px");
					$(".y_resetbtnbx").css("padding-top","0px");
				}else{
					$("#resigetNameError").text("您输入的手机号已存在！");
					$("#checkResigetName").val("false");
				}
		});
}


Comps.RegisterComp.prototype.checkCustomerName = function(){
	var customerName = $("#customerName").val();
	if(customerName==""){
		$("#customerNameError").text("请输入用户名");
		$("#checkCustomerName").val("false");	
		return;
	}
	var lengths=0;
	var cn_begin=4;
	  for (var i = 0; i < customerName.length; i++) {
		  var onelength = customerName.charCodeAt(i);
		  if(onelength>=0 && onelength<=128){
			  lengths+=1;
		  }else{
			  lengths+=2;
			  if(cn_begin>2){
			  	cn_begin=cn_begin-1;
			  }
		  }
	  }
	if(lengths<4 || lengths>20){
		$("#customerNameError").text("用户名为4-20个字符,可由字母,汉字,数字,'-','_'组成");
		$("#checkCustomerName").val("false");	
		return;	
	}
	var nameReg=/^[a-zA-Z0-9\u4e00-\u9fa5-_]{4,20}$/;
	if(cn_begin==2){
		nameReg=/^[a-zA-Z0-9\u4e00-\u9fa5-_]{2,20}$/;
	}else if(cn_begin==3){
		nameReg=/^[a-zA-Z0-9\u4e00-\u9fa5-_]{3,20}$/;
	}
	if(nameReg.test(customerName)){
		var url = ContextPath+"/registerComp/checkCustomerName";
		$.ajaxSettings.async = false;
		$.getJSON(url,{customerName:customerName,ranNum:Math.random()},function(data){
			if(data=="true"){
				$("#customerNameError").text("用户名已存在");
				$("#checkCustomerName").val("false");	
				return;	
			}else{
				$("#customerNameError").text("");
				$("#checkCustomerName").val("true");
			}
		});	
	}else{
		$("#customerNameError").text("用户名为4-20个字符,可由字母,汉字,数字,'-','_'组成");
		$("#checkCustomerName").val("false");	
		return;		
	}
}

Comps.RegisterComp.prototype.checkInvitationCode = function(){
	var invitationCode = $("#invitationCode").val();
	if(invitationCode==""){
		$("#checkInvitationCode").val("true");	
		$("#invitationCodeError").text("");
		return;
	}
		var url = ContextPath+"/registerComp/checkInvitationCode";
		$.ajaxSettings.async = false;
		$.getJSON(url,{invitationCode:invitationCode,ranNum:Math.random()},function(data){
			if(data=="noexist"){
				$("#invitationCodeError").text("邀请码不存在");
				$("#checkInvitationCode").val("false");	
				return;	
			}else if(data=="used"){
				$("#invitationCodeError").text("邀请码已使用");
				$("#checkInvitationCode").val("false");	
				return;	
			}else{
				$("#invitationCodeError").text("");
				$("#checkInvitationCode").val("true");
			}
		});	
}


Comps.RegisterComp.prototype.sendMobileCode = function(){
	var sendMobile = $("#resigetName").val();
	var url = ContextPath+"/registerComp/sendMobileCode";	
	$.getJSON(url,{sendMobile:sendMobile,ranNum:Math.random()},function(data){
			if(data.flag==false){
				$("#mobileCodeError").text("短信发送次数过多!");
			}else{
				$("#mobileCodeError").text("");
				$("#sessionId").val(data.sessionId);
			}
	})
}

//验证短信验证码
Comps.RegisterComp.prototype.checkMobileCode = function(){
	var sendMobile = $("#resigetName").val();
	var mobileCode = $("#mobileCode").val();
	var sessionId = $("#sessionId").val();
	if(mobileCode != ""){
		$("#mobileCodeError").text("");
		var url = ContextPath+"/registerComp/checkMobileCode";
		$.ajaxSettings.async = false;
		$.getJSON(url,{sendMobile:sendMobile,mobileCode:mobileCode,sessionId:sessionId,ranNum:Math.random()},function(data){
			   if(data==true){
					$("#mobileCodeError").text("");
					$("#checkMobileCode").val("true");
				}else{
					$("#mobileCodeError").text("您输入的短信验证码不匹配！");
					$("#checkMobileCode").val("false");
				}
		})
	}else{
		$("#mobileCodeError").text("请输入收到的验证码!!");	
		$("#checkMobileCode").val("false");
	}
}

//验证密码
Comps.RegisterComp.prototype.checkPassWord = function(){
	var passWord = $("#passWord").val();
	if(passWord != ""){
		var pwdReg = /^[a-zA-Z0-9\D]{6,20}$/;
		if(pwdReg.test(passWord)){
			$("#passWordError").text("");	
			$("#checkPassWord").val("true");	
		}else{
			$("#passWordError").text("请输入6-20位字母和数字等组合密码!");	
			$("#checkPassWord").val("false");	
		}
	}else{
		$("#passWordError").text("请输入登陆密码!");	
		$("#checkPassWord").val("false");
	}
}

//验证2次密码输入
Comps.RegisterComp.prototype.checkRepeatPassWord = function(){
	var passWord = $("#passWord").val();
	var repeatPassWord = $("#repeatPassWord").val();
	if(passWord==repeatPassWord){
		$("#repeatPassWordError").text("");	
		$("#checkRepeatPassWord").val("true");
	}else{
		$("#repeatPassWordError").text("2次密码输入不匹配!");	
		$("#checkRepeatPassWord").val("false");
	}
}

//验证码校验
Comps.RegisterComp.prototype.checkVerificationCode = function(){
	var verificationCode = $("#verificationCode").val();
	if(verificationCode != ""){
		var url = ContextPath+"/registerComp/checkVerificationCode";
		$.ajaxSettings.async = false;
		$.getJSON(url,{verificationCode:verificationCode,ranNum:Math.random()},function(data){
				if(data=="true"){
					$("#verificationCodeError").text("");
					$("#checkVerificationCode").val("true");
				}else{
					$("#verificationCodeError").text("您输入的验证码不匹配！");
					$("#checkVerificationCode").val("false");
				}
		})
	}else{
		$("#verificationCodeError").text("请输入验证码!");	
		$("#checkVerificationCode").val("false");	
	}			
}

//换一张，验证码
Comps.RegisterComp.prototype.flushValidateCode = function(){
	var validateImgObject = document.getElementById("validateImg");
	validateImgObject.src = ContextPath+"/getCustomerRegCode?time=" + new Date();
}

Comps.RegisterComp.prototype.saveCustomerRegister = function(){
	  var that = this;
	  var a_loginUrl = ContextPath+this.option.a_loginUrl;
	  if($("input[name='agreement']:checked").val() != "1"){
	  	$("#agreementError").text("请勾选我已阅读并同意《全网用户注册协议》");
	  	return false;
	  }else{
	  	$("#agreementError").empty();
	  }
	  that.checkResigetName();
	if("mobile"==$("#resigetNameType").val()){
		that.checkMobileCode();	
	}
	that.checkCustomerName();
	that.checkPassWord();
	that.checkRepeatPassWord();
	that.checkVerificationCode();
	
	var checkResigetName2 = $("#checkResigetName").val();
	var checkMobileCode2 = $("#checkMobileCode").val();
	var checkCustomerName2 = $("#checkCustomerName").val();
	var checkPassWord2 = $("#checkPassWord").val();
	var checkRepeatPassWord2 = $("#checkRepeatPassWord").val();
	var checkVerificationCode2 = $("#checkVerificationCode").val();
	var checkInvitationCode = $("#checkInvitationCode").val();
	if(checkResigetName2=="true"&& 
			checkMobileCode2=="true"&& 
			checkPassWord2=="true"&& 
			checkRepeatPassWord2=="true"&& 
			checkVerificationCode2=="true"&&
			checkCustomerName2=="true"&&
			checkInvitationCode=="true"){
		var resigetNameType = $("#resigetNameType").val();
		var resigetName = $("#resigetName").val();
		var customerName = $("#customerName").val();
		var mobileCode = $("#mobileCode").val();
		var passWord = $("#passWord").val();
		var pwdStrength = $("#pwdStrength").val()+"";
		var repeatPassWord = $("#repeatPassWord").val();
		var invitationCode = $("#invitationCode").val();
		var verificationCode = $("#verificationCode").val();

		 $.ajax({
			 type: "POST",
		      url: ContextPath+"/registerComp/save",
		      data: {
		    	  resigetNameType : resigetNameType,
		    	  resigetName : resigetName,
		    	  customerName : customerName,
		    	  mobileCode : mobileCode,
		    	  passWord : passWord,
		    	  pwdStrength : pwdStrength,
		    	  repeatPassWord : repeatPassWord,
		    	  invitationCode : invitationCode,
		    	  verificationCode : verificationCode
		      },
		      dataType: "json",
		      success: function(data){
		    	  if(data.flag == true){
		    		  alert("注册成功！请登录");
		    		  window.location.href = a_loginUrl;
		    	  }else{
		    		  alert(data.error_Msg);
		 			  return false;
		    	  }
		      }
		});
	}
}



//***********************找回密码*******************
Comps.FindPwdComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
	this.wait = 60;

	this.nameHidden="";
	this.codeHidden="";
	this.codeHidden2="";
	
	this.pwdHidden="";
	this.confirmHidden="";
}

Comps.FindPwdComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	that.flushValidateCode();//刷新验证码
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$("#"+compId+"_a_login").attr("href",ContextPath+this.option.a_loginUrl).html(this.option.a_loginName);
		$("#"+compId+"_a_index").attr("href",ContextPath+this.option.a_indexUrl).html(this.option.a_indexName);
		
		that.bindSomeEvent();
		Utils.ajaxLoadComplate(that);
	}else{
		that.bindSomeEvent();
		Utils.ajaxLoadComplate(that);
	}
}


//绑定事件
Comps.FindPwdComp.prototype.bindSomeEvent=function(){
	var compId = this.compId;
	var that = this;
	
	$("#img_changecode").click(function(){
		that.flushValidateCode();
	});
	
	$("#a_changecode").click(function(){
		that.flushValidateCode();
	});
	
	$("#btnnextstep").click(function(){
		that.nextStep2();
	});
	
	$("#a_nextStep3").click(function(){
		that.nextStep3();
	});
	
	$("#a_nextStep4").click(function(){
		that.nextStep4();
	});
	
	//修改密码强弱校验  
	 $("#newpwd").change(function(e) {
		 var newpwd = $(this).val();
	 	 EvalPwd(newpwd) ;
	 	if(ClientSideStrongPassword(newpwd,gSimilarityMap,gDictionary))
	    {	
		    $("input[name='pwdStrength']:hidden").val("3");
	    }
	    else if(ClientSideMediumPassword(newpwd,gSimilarityMap,gDictionary))
	    {
		    $("input[name='pwdStrength']:hidden").val("2");
	    }
	    else if(ClientSideWeakPassword(newpwd,gSimilarityMap,gDictionary))
	    {
		    $("input[name='pwdStrength']:hidden").val("1");
	    }
	    else
	    {
		    $("input[name='pwdStrength']:hidden").val("0");
	    }
	 });  
	 
	 //修改密码强弱校验  
	 $("#newpwd").keyup(function(e) {
		 var newpwd = $(this).val();
	 	 EvalPwd(newpwd) ;
	 	if(ClientSideStrongPassword(newpwd,gSimilarityMap,gDictionary))
	    {	
		    $("input[name='pwdStrength']:hidden").val("3");
	    }
	    else if(ClientSideMediumPassword(newpwd,gSimilarityMap,gDictionary))
	    {
		    $("input[name='pwdStrength']:hidden").val("2");
	    }
	    else if(ClientSideWeakPassword(newpwd,gSimilarityMap,gDictionary))
	    {
		    $("input[name='pwdStrength']:hidden").val("1");
	    }
	    else
	    {
		    $("input[name='pwdStrength']:hidden").val("0");
	    }
	 });
	 
	//点击获取手机验证码
	 $("#getMobileCode").click(function(){
		 that.time(this);
	 	var customerUuid=$("#uuid").val();
	 	var mobile=$("#mobileHidden").val();
	 	var url = ContextPath+"/findpwdComp/getMobileCode";
	 	$.getJSON(url,{"customerUuid":customerUuid,"mobile":mobile,"ranNum":Math.random()},function(data){
	 		if(data.flag == true){
	 			$("#sendMobileCodeTip").show();
	 			$("#sessionId").val(data.sessionId);
	 		}
	 		else{
	 			alert("手机号错误！");
	 		}
	 	});
	 });

	 //点击发送验证邮件
	 $("#sendValidateEmail").click(function(){
	 	$("#sendValidateEmail").attr("disabled",true);
	 	var customerUuid=$("#uuid").val();
	 	var email=$("#emailHidden").val();
	 	var url = ContextPath+"/findpwdComp/sendValidateEmail";
	 	$.get(url,{"customerUuid":customerUuid,"email":email,"ranNum":Math.random()},function(data){
	 		if(data=="success"){
	 			$("#sendValidateEmailTip").show();
	 		}
	 	});
	 });

}


//换一张，验证码
Comps.FindPwdComp.prototype.flushValidateCode = function(){
	$("#validateImg").attr("src",ContextPath + "/getStoreFindPwdCode?time=" + Math.random());
}

//点击下一步提交
Comps.FindPwdComp.prototype.nextStep2 = function(){
	var that = this;
	var compId = this.compId;
	var accountName = $("#accountName").val();
	var code =$("#verificationCode").val();
	
	that.checkAccountName(accountName);
	that.checkVerificationCode(code);
	
	if(this.nameHidden=="true"&&this.codeHidden=="true"){
		$.ajax({
			  type: "POST",
		      url: ContextPath+"/findpwdComp/doStep1",
		      dataType : "json",
		      data: {accountName:accountName},
		      success: function(data){
		    	  $("#"+compId+"_restep2").show();
		    	  $("#"+compId+"_restep1").hide();
		    	  $("#uuid").val(data.uuid);
		    	  $("#mobileHidden").val(data.mobile);
		    	  $("#emailHidden").val(data.email);
		    	  that.initStep2();
		      }
		});
	}
}

//校验账户名称
Comps.FindPwdComp.prototype.checkAccountName = function(accountName){
	if(accountName==""){
		$("#accountNameError").text("请填写您的注册手机号码!");
		$("#checkAccountName").val("false");
	}else{
		$("#accountName").keyup(function(){
			$("#accountNameError").text("");
		});
		
		var url= ContextPath+"/findpwdComp/checkAccountName";
		$.get(url,{"accountName":accountName,"ranNum":Math.random()},function(data){
			if(data=="true"){
				$("#accountNameError").text("");
				$("#checkAccountName").val("true");
			}else if(data=="false"){
				$("#accountNameError").text("您输入的账号名不存在，请核对后重新输入");
				$("#checkAccountName").val("false");
			}else{
				$("#accountNameError").text("帐号异常，请联系管理员!");
				$("#checkAccountName").val("false");
			}
		});
	}
	this.nameHidden=$("#checkAccountName").val();
}

//校验随机验证码
Comps.FindPwdComp.prototype.checkVerificationCode = function(code){
	if(code==""){
		$("#codeError").text("请输入验证码");	
		$("#checkVerificationCode").val("false");
	}else{
		$("#verificationCode").keyup(function(){
			$("#codeError").text("");
		});
		
		var url = ContextPath+"/findpwdComp/checkVerificationCode";
		$.get(url,{"verificationCode":code,"ranNum":Math.random()},function(data){
			if(data=="true"){
				$("#codeError").text("");
				$("#checkVerificationCode").val("true");
			}else{
				$("#codeError").text("验证码输入错误");
				$("#checkVerificationCode").val("false");
			}
		});
	}
	this.codeHidden=$("#checkVerificationCode").val();
}


///////////******************************22222222222222222



Comps.FindPwdComp.prototype.initStep2 = function(){
	var mobile=$("#mobileHidden").val();
	var email=$("#emailHidden").val();
	
	if(mobile!=""){
		$("#mobileSpan").html(mobile.substring(0,3)+"****"+mobile.substring(7,11));
	}

	if(email!=""){
		var index=email.indexOf("@");
		var prefix = email.substring(0,index);
		if(prefix.length >=4){
			$("#emailSpan").html(email.substring(0,2)+"****"+email.substring(index-2,index)+email.substring(index));
		}else{
			$("#emailSpan").html(email.substring(0,1)+"****"+email.substring(index-1,index)+email.substring(index));
		}
	}
	
	//选择验证类型：手机或者邮箱验证
	if($("#verifyType").val()=="1"){
		$("#y_yzmobel,y_yzmobeltxt").show();
		$("#y_yzemail,y_yzemailtxt").hide();
	}else{
		$("#y_yzmobel,y_yzmobeltxt").hide();
		$("#y_yzemail,y_yzemailtxt").show();
	}
	
	//找回密码第二步，选择验证方式切换时事件
	var map={"1":"y_yzmobel","2":"y_yzemail"};
	$("#verifyType").bind("change", function(){
		var divId = map[this.value];
		$("#"+divId).show().siblings(".y_yzqhbox").hide();
		$("#"+divId+"txt").show().siblings(".y_resettext").hide();
	});
}


//点击下一步提交
Comps.FindPwdComp.prototype.nextStep3 = function(){
	var that = this;
	var compId = this.compId;
	var code = $("#mobileCode").val();
	that.checkMobileCode(code);
	if(this.codeHidden2=="true"){
		var uuid=$("#uuid").val();
		$.ajax({
			  type: "POST",
		      url: ContextPath+"/findpwdComp/doStep2",
		      dataType : "json",
		      data: {uuid:uuid},
		      success: function(data){
		    	  $("#"+compId+"_restep3").show();
		    	  $("#"+compId+"_restep1").hide();
		    	  $("#"+compId+"_restep2").hide();
		    	  $("#uuid2").val(data.uuid);
		      }
		});
	}
}

//校验手机验证码是否正确
Comps.FindPwdComp.prototype.checkMobileCode = function(code){
	if(code==""){
		$("#mobileCodeError").html("请输入手机验证码");
		$("#checkMobileCode").val("false");
	}else{
		$("#mobileCode").keyup(function(){
			$("#mobileCodeError").html("");
		});
		var customerUuid=$("#uuid").val();
		var sessionId = $("#sessionId").val();
		var url = ContextPath+"/findpwdComp/checkMobileCode";
		$.get(url,{"customerUuid":customerUuid,"code":code,"sessionId":sessionId,"ranNum":Math.random()},function(data){
			if(data=="true"){
				$("#mobileCodeError").html("");
				$("#checkMobileCode").val("true");
			}else{
				$("#mobileCodeError").html("手机验证码有误");
				$("#checkMobileCode").val("false");
			}
		});
	}
	this.codeHidden2=$("#checkMobileCode").val();
}


//执行倒计时方法
Comps.FindPwdComp.prototype.time = function(o) {
  	var that = this;
	if (that.wait == 0) {
		$("#sendMobileCodeTip").hide();
	    o.removeAttribute("disabled");
	    o.value = "发送短信验证码";
	    that.wait = 60;
  	} else {
	    o.setAttribute("disabled", true);
	    o.value = that.wait + "秒后重发";
	    that.wait--;
	    setTimeout(function() {that.time(o)},1000)
    }
}

/////////************************************3333

//点击下一步提交
Comps.FindPwdComp.prototype.nextStep4 = function(){
	var that = this;
	var compId = this.compId;
	var newpwd=$("#newpwd").val();
	var confirmPwd=$("#confirmpwd").val();
	that.checkNewPwd(newpwd);
	that.checkConfirmPwd(newpwd,confirmPwd);
	
	if(this.pwdHidden=="true"&&this.confirmHidden=="true"){
		var uuid = $("#uuid2").val();
		var pwdStrength = $("#pwdStrength").val();
		$.ajax({
			  type: "POST",
		      url: ContextPath+"/findpwdComp/doStep3",
		      dataType : "json",
		      data: {uuid:uuid,newpwd:newpwd,pwdStrength:pwdStrength},
		      success: function(data){
		    	  $("#"+compId+"_restep4").show();
		    	  $("#"+compId+"_restep1").hide();
		    	  $("#"+compId+"_restep2").hide();
		    	  $("#"+compId+"_restep3").hide();
		      }
		});
	}
}

Comps.FindPwdComp.prototype.checkNewPwd = function(newpwd){
	var reg=/^[a-zA-Z0-9_-]{6,18}$/;
	if(newpwd==""){
		$("#checkPwd").val("false");
		$("#pwdError").html("请输入新密码");
	}else{
		$("#newpwd").keyup(function(){
			$("#pwdError").html("");
		});
		
		if(reg.test(newpwd)){
			$("#checkPwd").val("true");
			$("#pwdError").html("");
		}else{
			$("#checkPwd").val("false");
			if(newpwd.length<6||newpwd.length>20){
				$("#pwdError").html("密码长度有误");
			}else{
				$("#pwdError").html("密码错误");
			}
		}
	}
	this.pwdHidden=$("#checkPwd").val();
}

Comps.FindPwdComp.prototype.checkConfirmPwd = function(newpwd,confirmPwd){
	if(confirmPwd==""){
		$("#checkConfirmPwd").val("false");
		$("#confirmPwdError").html("请再一次输入密码");
	}else{
		$("#confirmpwd").keyup(function(){
			$("#confirmPwdError").html("");
		});
		
		if(newpwd!=confirmPwd){
			$("#checkConfirmPwd").val("false");
			$("#confirmPwdError").html("两次密码输入不一致");
		}else{
			$("#checkConfirmPwd").val("true");
			$("#confirmPwdError").html("");
		}
	}
	this.confirmHidden=$("#checkConfirmPwd").val();
}



////*************************IM咨询****************
Comps.ImServiceComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
}

Comps.ImServiceComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	
	
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		var appId = this.option.appId;
    	var appToken = this.option.appToken;
    	var storeUuid = $("#"+compId+"_storeUuid").val();
    	$("#"+compId+"_storeUuid").val(storeUuid);
    	$("#appId").val(appId);
    	$("#appToken").val(appToken);
        //异步获取数据
        $.ajax({
            type: "GET",
            url: ContextPath+"/imServiceComp/ajaxLoadData",
            data: {"storeUuid" : storeUuid },
            dataType: "json",
            success: function(data) {
            	$("#navbar_user_account").val(data.userUuid);
            	$("#"+compId+"_photoUrl").attr("src", data.profilePic);
    			$("#"+compId+"_nickName").html(data.nickname);
            	$("#"+compId+"_storeName").html(data.storeName);
            	$("#im_contact_list .active").attr("id","im_contact_"+storeUuid).attr("contact_you",storeUuid);
            	
            	that.bindSomeEvent();
            	Utils.ajaxLoadComplate(that);
            }
        });
	}else{
		that.bindSomeEvent();
		Utils.ajaxLoadComplate(that);
	}
}

//绑定事件
Comps.ImServiceComp.prototype.bindSomeEvent=function(){
	var compId = this.compId;
	var that = this;
	var loginTopic = this.option.loginTopic;
	//发布主题，判断是否登录
	$("#"+compId+"_a_im").click(function(){
		if(loginTopic != null && loginTopic != ""){
			CompMessage.publish(loginTopic,{},function(data){
				setInterval(function(){window.onbeforeunload=null},0);
				IM.init();
				IM.DO_login();
				$(".bbc_service").slideToggle();
				$.getJSON(ContextPath+"/imServiceComp/getCustomerInfo", {}, function(data) {
					if (data){
						$("#"+compId+"_photoUrl").attr("src", data.profilePic);
		    			$("#"+compId+"_nickName").html(data.nickname);
					}
				});
			});
		}
	});
	
	var storeUuid = $("#"+compId+"_storeUuid").val();
	$("#im_contact_"+storeUuid).click(function(){
		IM.DO_chooseContactList('C', storeUuid,true)
	});
	
	$("#"+compId+"_closeChatBox").click(function(){
		$(".bbc_service").slideToggle();
	});
	
}

//IM咨询弹出框
Comps.ImServiceComp.prototype.closeChatBox = function(){
	$(".bbc_service").slideToggle()
}


////*******************************QQ在线咨询************
Comps.CustomServiceComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
}

Comps.CustomServiceComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$.ajax({
			  type: "GET",
		      url: ContextPath+"/customServiceComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
		    	  if(data != null && data.length > 0){
		    			var htmlStr = "";
		    			for(var i =0;i<data.length;i++){
		    				htmlStr += "<a href='javascript:void(0)'>"+data[i].qqName+"：</a>";
		    				htmlStr += "<a target= '_blank'  href='http://wpa.qq.com/msgrd?v=3&uin="+data[i].qqNumber+"&site=qq&menu=yes' ><img border='0' src='http://wpa.qq.com/pa?p=2:"+data[i].qqNumber+":51' alt='点这里给我发消息' /></a>";
		    			}
		    			$("#"+compId+"_qqdiv").html(htmlStr);
		    		}
		    	  
		    	   Utils.ajaxLoadComplate(that);
		      }
		});
	}else{
		Utils.ajaxLoadComplate(that);
	}
}



//////*************************快速入口组件****************
Comps.SideEnteranceComp = function(option){
	this.compId = option.compId;
	this.needAsyncInit = option.needAsyncInit;
	this.option = option;
	//监听页面宽度，右侧边栏的帐号、收藏、调查问卷的显示、隐藏
	this.rtfixshow = false,
	this.rtboxshow = false;
}

Comps.SideEnteranceComp.prototype.init = function(){
	var that = this;
	var compId = this.compId;
	//1.是否懒加载，如果是懒加载，则下面数据通过ajax请求，渲染html页面
	if(this.needAsyncInit){
		$.ajax({
			 type: "GET",
		      url: ContextPath+"/loginComp/ajaxLoadData",
		      data: {},
		      dataType: "json",
		      success: function(data){
				  $("#loginName1").val(data.loginName);
				  $("#pwd1").val(data.pwd);
				  var hasVilidateCode = data.hasVilidateCode;
				  $("#hasVilidateCode1").val(hasVilidateCode);
				  var remember = data.remember;
				  if(remember == "on"){
					  $("#remember").attr("checked","checked");
				  }else{
					  $("#remember").removeAttr("checked");
				  }
		      }
		});
		if(this.option.loginIsShow == "0"){
			$("#"+compId+"_pr_userlogin").hide();
		}
		if(this.option.cartIsShow == "0"){
			$("#"+compId+"_w_cart").hide();
		}
		if(this.option.collectionIsShow == "0"){
			$("#"+compId+"_pr_mycollection").hide();
		}
		if(this.option.quesNaireIsShow == "0"){
			$("#"+compId+"_pr_quesnaire").hide();
		}else{
			$("#"+compId+"_pr_quesnaire").attr("href",this.option.quesNaireUrl);
		}
		if(this.option.qqIsShow == "0"){
			$("#"+compId+"_pr_qq").hide();
		}
		if(onlineIsShow == "0"){
			$("#baidusq").hide();
		}
		
		$("#"+compId+"_a_reg").attr("href",ContextPath+this.option.a_forgetPwdUrl).html(this.option.a_forgetPwdName);
		$("#"+compId+"_a_forgetpwd").attr("href",ContextPath+this.option.a_regUrl).html(this.option.a_regName);
		Utils.ajaxLoadComplate(that);
	}else{
		var loginIsShow = $("#"+compId+"_loginIsShow").val();
		var cartIsShow = $("#"+compId+"_cartIsShow").val();
		var collectionIsShow = $("#"+compId+"_collectionIsShow").val();
		var quesNaireIsShow = $("#"+compId+"_quesNaireIsShow").val();
		var qqIsShow = $("#"+compId+"_qqIsShow").val();
		var onlineIsShow = $("#"+compId+"_onlineIsShow").val();
		if(loginIsShow == "0"){
			$("#"+compId+"_pr_userlogin").hide();
		}
		if(cartIsShow == "0"){
			$("#"+compId+"_w_cart").hide();
		}
		if(collectionIsShow == "0"){
			$("#"+compId+"_pr_mycollection").hide();
		}
		if(quesNaireIsShow == "0"){
			$("#"+compId+"_pr_quesnaire").hide();
		}
		if(qqIsShow == "0"){
			$("#"+compId+"_pr_qq").hide();
		}
		if(onlineIsShow == "0"){
			$("#baidusq").hide();
		}
		
		Utils.ajaxLoadComplate(that);
	}
	
	var customerIndexUrl = this.option.customerIndexUrl;
	$.getJSON(ContextPath+"/sideEnteranceComp/isLogin",{},function(data){
		if(data.flag == true){
			$("#"+compId+"_userlogin").show();
			$("#"+compId+"_nologin").remove();
			$(".y_ifixed").addClass("y_haslogoin").removeClass("y_nologin");
			$("#"+compId+"_userphoto").attr("src",data.profilePic);
			$("#"+compId+"_customer_index").attr("href",ContextPath + "/" +customerIndexUrl);
		}else{
			$("#"+compId+"_nologin").show();
			$("#"+compId+"_userlogin").remove();
		}
	});
	//绑定事件
	that.bindSomeEvent();
	//加载收藏商品
	that.loadFavoteProduct();
	
	that.rtcartshow();
	that.loadAjaxCart();
}


//绑定事件
Comps.SideEnteranceComp.prototype.bindSomeEvent=function(){
	var compId = this.compId;
	var that = this;
    
	$("#pwd1").blur(function(){
		$("#pwd1").val(hex_md5($("#pwd1").val()));
	});
 	
//	$(".y_userbtn").click(function() {
//		//$(".y_rtdlbox").removeClass("y_botshow").css({"display":"block","top":"34px","bottom":"auto"})
//	});
	
	$('#domainForm222').each(function() {
	    var id = $(this).attr('id');  //获取表单的id
	    $("#" + id).validate({   //验证表单
	        errorElement: 'span',  //输入错误时的提示标签
	        errorClass: 'help-block has-error',  //输入错误时的提示标签类名
	        errorPlacement: function(error, element) {  //输入错误时的提示标签显示的位置
	            if(element.parents(".input-group").length > 0){
	            		element.parents(".input-group").after(error);
	            }else if(element.parents(".y_validatainput").length > 0){
	            		element.parents(".y_validatainput").after(error);
	            }
	            else if(element.parents("label").length > 0) {
	                element.parents("label").after(error);
	            }else {
	                element.after(error);
	            }
	        },
	        highlight: function(label) {   //输入错误时执行的事件
	            $(label).closest('.form-group').removeClass('has-error has-success').addClass('has-error');
	        },
	        success: function(label) {   //输入正确时执行的事件
	            label.addClass('valid').closest('.form-group').removeClass('has-error has-success').addClass('has-success');
	        },
	        onkeyup: function(element) {   //验证元素输入值时按钮松开执行的事件
	            $(element).valid();
	        },
	        onfocusout: function(element) {   //验证元素失去焦点时进行验证
	            $(element).valid();
	        },                
	        submitHandler: function(form){
	        	that.login();
			}
	    });
	});
	
	$("#btn_customer_login").click(function(){
		that.login();
	});
	
	//返回顶部js
	$(".y_ifixed .y_totop").click(function() {
	    $("html,body").animate({
	        scrollTop: '0px'
	    }, 300);
	});

	
	$(window).resize(function() {
	    if (!$(".y_rtfixbx").hasClass("y_showrt")) {
	        that.rtcartshow();
	    }
	});
	
	$(".y_rtfixbx").click(function(event) {
	    event.stopPropagation();
	});
	
	//右侧导航登录后 点击购物车弹出、关闭购物车信息
	$(".y_rtfixbx").on("click", ".y_rtcart", function() {
		var customerIndexUrl = that.option.customerIndexUrl;
		$.getJSON(ContextPath+"/sideEnteranceComp/isLogin",{},function(data){
			if(data.flag == true){
				$("#"+compId+"_userlogin").show();
				$("#"+compId+"_nologin").remove();
				$(".y_ifixed").addClass("y_haslogoin").removeClass("y_nologin");
				$("#"+compId+"_userphoto").attr("src",data.profilePic);
				$("#"+compId+"_customer_index").attr("href",ContextPath +"/"+ customerIndexUrl);
			}else{
				$("#"+compId+"_nologin").show();
				$("#"+compId+"_userlogin").remove();
			}
		});
	    if (!$(".y_rtctbx").is(".y_rtmsshow")) {
	        that.y_rtctlopen();
	        $(this).addClass("y_xzcur");
	        $(".y_rtlove").removeClass("y_xzcur");
	        $(".y_rtctbx").addClass("y_rtmsshow");
	        $(".y_rtlovebx").removeClass("y_rtmsshow");
	        $(".y_rtfixbx").animate({
	            width: "310px"
	        }, 300);
	        $('.add-popover,[rel=popover]').popover('hide');

	    } else {
	        that.y_rtctloclose();
	        $('.add-popover,[rel=popover]').popover('hide');
	    };
	    that.loadAjaxCart();
	   //加载收藏商品
		that.loadFavoteProduct();
	});
	//右侧导航登录后 点击我的收藏弹出、关闭收藏信息
	$(".y_rtfixbx").on("click", ".y_haslogoin .y_rtlove", function() {
	    if (!$(".y_rtlovebx").is(".y_rtmsshow")) {
	        that.y_rtctlopen();
	        $(this).addClass("y_xzcur");
	        $(".y_rtcart").removeClass("y_xzcur");
	        $(".y_rtlovebx").addClass("y_rtmsshow");
	        $(".y_rtctbx").removeClass("y_rtmsshow");
	        $(".y_rtfixbx").animate({
	            width: "270px"
	        }, 300);
	    } else {
	        that.y_rtctloclose();
	    };
	});
	//右侧购物车或收藏显示时，关闭按钮的事件
	$(".y_closertms").click(function() {
	    that.y_rtctloclose();
	});

	//右侧导航点击显示登录弹出框
	$(".y_rtfixbx").on("click", ".y_nologin .y_userbtn", function() {
	    $(".y_rtdlbox").removeClass("y_botshow").css({
	        "display": "block",
	        "top": "34px",
	        "bottom": "auto"
	    })
	});
	$(".y_nologin .y_userbtn,.y_nologin .y_rtcart,.y_nologin .y_rtlove").mouseleave(function() {
		$(".y_rtdlbox").hide();
	    $(".y_rtdlbox").hover(function() {
	        $(this).show();
	    }, function() {
	        $(this).hide();
	    });
	});

	$(".y_rtfixbx").on("click", ".y_nologin .y_rtlove", function() {
	    $(".y_rtdlbox").addClass("y_botshow").css({
	        "display": "block",
	        "top": "auto",
	        "bottom": "70px"
	    })
	});
	//点击关闭右侧登陆弹出框的事件
	$(".y_closedlbx").click(function() {
	    $(this).parents(".y_rtdlbox").hide();
	});
	//右侧悬浮侧边栏鼠标移上时显示、隐藏部分模块
	$(".y_ifixed").hover(function() {
	    if (that.rtfixshow == false) {
	        $(".y_ifixed").removeClass("y_rtcthide");
	    };
	}, function() {
	    if (that.rtfixshow == false && that.rtboxshow == false) {
	        $(".y_ifixed").addClass("y_rtcthide");
	    };
	});

	//除首页外其他页面鼠标移上全部商品分类时展示分类树
	$('.y_produall').hover(function() {
	    $(this).find('.y_prudaltc').show();
	}, function() {
	    $(this).find('.y_prudaltc').hide();
	});

	$(".pop-qq").on('click', function() {
		that.rtfixshow = true;
	})

	$('.add-popover,[rel=popover]').on('hidden.bs.popover', function() {
		that.rtfixshow = false;
	})

	// Bootstrap tooltip
	if ($.fn.tooltip) {
	    $('.add-tooltip,[rel=tooltip]').tooltip();
	};

	// Bootstrap popover
	if ($.fn.popover) {
	    $('.add-popover,[rel=popover]').popover({
	        trigger: "click",
	        html:true,
	        content:this.option.qqListStr
	    });
	};


	//根据.progress-animate的data-width属性动态设置元素的宽度，如果页面引入了jquery.appear.js则滚动到元素所在位置才设置否则默认设置
	if ($.fn.appear) {
	    $('.progress-animate').appear();
	    $('.progress-animate').on('appear', function() {
	        var $this = $(this),
	            progressVal = $(this).data('width'),
	            progressText = $this.find('.progress-text');
	        $this.css({
	            'width': progressVal + '%'
	        }, 400);
	        progressText.fadeIn(500);
	    });

	} else {
	    $('.progress-animate').each(function() {
	        var $this = $(this),
	            progressVal = $(this).data('width'),
	            progressText = $this.find('.progress-text');
	        $this.css({
	            'width': progressVal + '%'
	        }, 400);
	        progressText.fadeIn(500);
	    });
	}

	//收藏商品成功弹出框内的商品滚动
	if ($(".y_collpdowl").length > 0) {
	    $('.y_collpdowl.owl-carousel').owlCarousel({
	        items: 3,
	        itemsDesktop: false,
	        itemsDesktopSmall: false,
	        itemsTablet: false,
	        pagination: false,
	        navigationText: false,
	        scrollPerPage: true,
	        autoPlay: 5000,
	        slideSpeed: 800,
	        navigation: true
	    });
	};

	
	$("#shoppingCart").on("click", "[id^='addstock_']", function(){	
			var operId = $(this).attr("id") ;					
						
			var stockStr = operId.replace("addstock_","stock_") ;			
			var changeNum = $("#"+stockStr).val() ;			
			
			//调用异步更新数量，计算价格			
			that.ajaxChangeNum(operId ,changeNum) ;
	})
	
	$("#shoppingCart").on("click", "[id^='reducestock_']", function(){			
			var operId = $(this).attr("id") ;								
			var stockStr = operId.replace("reducestock_","stock_") ;			
			var changeNum = $("#"+stockStr).val() ;
			if(parseInt(changeNum)==1) {
				return ;
			}
			
			//调用异步更新数量，计算价格			
			that.ajaxChangeNum(operId ,changeNum) ;
	})
	
	//弹出确认是否删除框
	$("#shoppingCart").on("click", "[id^='remove_']", function(){	
			var operId = $(this).attr("id") ;							
			
			//调用异步更新数量，计算价格		
			that.ajaxRemove(operId) ;
	})

	//购物车商品全选	
	$("#shoppingCart").on("click", "[id='CheckAll']", function(){		
		var flag = $(this).prop("checked"); 					
		if(flag) {			
			$(':checkbox').prop('checked',true); 	
		}else{			 			
			$(':checkbox').prop('checked',false); 	
		}	
		that.ajaxChangeChoose("allRecords" ,flag) ;
	}) 
		
	$("#shoppingCart").on("blur", "[id^='stock_']", function(){				
		var operId = $(this).attr("id") ;		
		var buyNum = $(this).val().replace(/[^\d]/g, '');
		if(buyNum == "") {
			buyNum = 1 ;
		}		
		$(this).val(buyNum);			
		that.ajaxChangeNum(operId ,buyNum) ;	
	})
	
	//购物车商户复选框选中全选			
	$("#shoppingCart").on("click", "[id^='store_']", function(){	
		var flag = $(this).prop("checked"); 	
		var operId = $(this).attr("id") ;			
		var operationId = operId.replace("store_" ,"product_") ;		
		if(flag) {
			$("[id^='"+operationId+"']").prop('checked',true); 		
		}	else{
			$("[id^='"+operationId+"']").prop('checked',false); 		
		}
		
		var productIds = "" ;
		$("[id^='"+operationId+"']").each(function(index){ 
			var productCheckId = $(this).attr("id") ;	
			productIds = productCheckId+";"+productIds ;
		})			

		that.ajaxChangeChoose(productIds ,flag) ;
	}) 
	
	//购物车商品选中框操作
	$("#shoppingCart").on("click", "[id^='product_']", function(){			
			var operId = $(this).attr("id") ;						
			var flag = $(this).prop("checked"); 			
			
			that.ajaxChangeChoose(operId ,flag) ;		
	})
		
	//购物车去结算
	//1.判断是否登录，如果未登录，则弹出登录框
	//2.如果已登录，则进入下一步
	$("#shoppingCart").on("click", "[id^='goBlance']", function(){
			var loginUrl = ContextPath+"/cart/isLogin"	
			$.get(loginUrl,{ranNum:Math.random()} ,function(data){
				if("0"==data) {
					//弹出登录框
					is_right_cart_buy="true";
					$("#modal-login-form").modal();
				}else{
					$("#cartForm").submit() ;
				}
			})	
	})
	
	$(".y_topcart").on("click", "[id^='goBlance']", function(){
			var loginUrl = ContextPath+"/cart/isLogin"	
			$.get(loginUrl,{ranNum:Math.random()} ,function(data){
				if("0"==data) {
					//弹出登录框
					$("#modal-login-form").modal();
				}else{
					$("#cartForm").submit() ;
				}
			})	
	})
	
	//加载 购物车
	$("#w_cart").click(function(){
			that.loadAjaxCart();
	});	
	
}


//加载会员收藏的商品	 
Comps.SideEnteranceComp.prototype.loadFavoteProduct = function(){
	var url = ContextPath+"/sideEnteranceComp/platRightFavoriteProduct";
	$.post(url,{ranNum:Math.random()},
			function(data){
				$(".y_rtlovebx").html(data);
			}
	);
}
	
Comps.SideEnteranceComp.prototype.login = function(){
	var loginName = $("#loginName1").val();
	if(loginName == null || loginName == ""){
		$("#error").css("display","block");
		$(".alert").show();
		$(".alert").html("请输入手机号/用户名!");
		return false;
	 }
	var pwd = $("#pwd1").val();
	if(pwd == null || pwd == ""){
		$("#error").css("display","block");
		$(".alert").show();
		$(".alert").html("请输入密码!");
		return false;
	}
	var hasVilidateCode =  $("#hasVilidateCode1").val()+"";
	var validateCode =  $("#validateCode").val();
	if(hasVilidateCode == "true"){
		 if(validateCode == null || validateCode == ""){
			 $("#error").css("display","block");
			 $(".alert").show();
			 $(".alert").html("请输入验证码!");
			 return false;
		 }
	}
	var remember = "";
	 $("input[name='remember']:checked").each(function(){
		 remember = $(this).val();
	 });
	$.get(ContextPath+"/sideEnteranceComp/quickRightLogin",
		{
			"loginName":loginName,
			"pwd":pwd,
			"hasVilidateCode":hasVilidateCode,
			"validateCode":validateCode,
			"remember" : remember,
			"type":"customer",
			ranNum : Math.random()
		},
		function(data) {
			if(data == "codeNull"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("验证码为空!");
			}else if(data == "codeError"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("验证码错误!");
			}else if(data == "loginError"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("用户名或者密码错误!");
			}else if(data == "hasCode"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("用户名或者密码错误!");
				$("#hasVilidateCode").val("true");
				$("#validateCodediv").css("display","block");
			}else if(data == "success"){
				$(".alert").hide();
				$(".alert").html(" ");
				$("#modal-login-form").modal("hide");
				window.location.reload();
			}
		});
}


Comps.SideEnteranceComp.prototype.login1 = function(){
	var loginName = $("#loginName1").val();
	if(loginName == null || loginName == ""){
		$("#error").css("display","block");
		$(".alert").show();
		$(".alert").html("请输入手机号/用户名!");
		return false;
	 }
	var pwd = $("#pwd1").val();
	if(pwd == null || pwd == ""){
		$("#error").css("display","block");
		$(".alert").show();
		$(".alert").html("请输入密码!");
		return false;
	}
	var hasVilidateCode =  $("#hasVilidateCode1").val()+"";
	var validateCode =  $("#validateCode1").val();
	if(hasVilidateCode == "true"){
		 if(validateCode == null || validateCode == ""){
			 $("#error").css("display","block");
			 $(".alert").show();
			 $(".alert").html("请输入验证码!");
			 return false;
		 }
	}
	var remember = "";
	 $("input[name='remember']:checked").each(function(){
		 remember = $(this).val();
	 });
	$.get(ContextPath+"/sideEnteranceComp/quickRightLogin",
		{
			"loginName":loginName,
			"pwd":pwd,
			"hasVilidateCode":hasVilidateCode,
			"validateCode":validateCode,
			"remember" : remember,
			"type":"customer",
			ranNum : Math.random()
		},
		function(data) {
			if(data == "codeNull"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("验证码为空!");
			}else if(data == "codeError"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("验证码错误!");
			}else if(data == "loginError"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("用户名或者密码错误!");
			}else if(data == "hasCode"){
				$("#error").css("display","block");
				$(".alert").show();
				$(".alert").html("用户名或者密码错误!");
				$("#hasVilidateCode").val("true");
			}else if(data == "success"){
				$(".alert").hide();
				$(".alert").html(" ");
				$("#modal-login-form").modal("hide");
				window.location.reload();
			}
		});
}


/* 刷新验证码 */
Comps.SideEnteranceComp.prototype.flushValidateCode = function(){
	 var validateImgObject = document.getElementById("validateImg");
	 validateImgObject.src = ContextPath+"/getCustomerLoginCode?time=" + new Date();
}


Comps.SideEnteranceComp.prototype.rtcartshow = function() {
    var boxwidth = $(".container").width(),
        winwidth = $(window).width();
    if ((winwidth / 2 - boxwidth / 2) < 1000) {
        if (!$(".y_ifixed").hasClass("y_rtcthide")) {
            $(".y_ifixed").addClass("y_rtcthide");
        };
        this.rtfixshow = false;
    } else {
        $(".y_ifixed").removeClass("y_rtcthide");
        this.rtfixshow = true;
    };
};

//右侧购物车、收藏信息的显示事件
Comps.SideEnteranceComp.prototype.y_rtctlopen = function() {
    var that = this;
	$(".y_rtfixbx").addClass("y_showrt");
    $(".y_ifixed").removeClass("y_rtcthide");
    //右侧购物车或收藏显示时，点击右侧区域以外的地方可以关闭
    $(document).one("click", function() {
        that.y_rtctloclose();
    });
    this.rtboxshow = true;
}


//右侧购物车、收藏信息的关闭事件
Comps.SideEnteranceComp.prototype.y_rtctloclose = function() {
    var that = this;
	$(".y_rtcart,.y_rtlove").removeClass("y_xzcur");
    $(".y_rtfixbx").removeClass("y_showrt");
    $(".y_rtctbx,.y_rtlovebx").removeClass("y_rtmsshow");
    $(".y_rtfixbx").animate({
        width: "35px"
    }, 300);
    that.rtcartshow();
    this.rtboxshow = false;
};


//页面修改购买数量
Comps.SideEnteranceComp.prototype.ajaxChangeNum = function(operId ,changeNum) {		
	var changeNumUrl = ContextPath+"/cart/ajaxchangeNums" ;			
	$.post(changeNumUrl,{productIdAndAttrId:operId,changeNum:changeNum,ranNum:Math.random()} ,function(data){
			$("#shoppingCart").addClass("y_rtmsshow");
			$("#shoppingCart").html(data) ;		
	})
}

//删除购物车中的商品
Comps.SideEnteranceComp.prototype.ajaxRemove = function(operId) {		
	var changeNumUrl = ContextPath+"/cart/ajaxremove" ;			
	$.post(changeNumUrl,{productIdAndAttrId:operId,ranNum:Math.random()} ,function(data){
			$("#shoppingCart").html(data) ;		
	})
}

//复选框是否选中
Comps.SideEnteranceComp.prototype.ajaxChangeChoose = function(operId ,flag) {		
	var changeNumUrl = ContextPath+"/cart/ajaxchangeChoose" ;			
	$.post(changeNumUrl,{productIdAndAttrId:operId,chooseState:flag ,ranNum:Math.random()} ,function(data){
			$("#shoppingCart").html(data) ;		
	})
}

//加载右侧购物车
Comps.SideEnteranceComp.prototype.loadAjaxCart = function(){
	var url = ContextPath+"/cart/ajaxcartshow" ;
	$.post(url,function(data){
		$("#shoppingCart").html(data);	
	});			
}